using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace PeDALS.Tools.AZ.PSTArchive.PSTData
{
    public class PSTBlockTrailer
    {
        private short mshtBlockLength;
        private short mshtBlockSignature;
        private int mintCRC;
        private UInt64 m64BIDraw;

        public PSTBlockTrailer(BinaryReader brReader, bool blnUnicode)
        {
            mshtBlockLength = brReader.ReadInt16();
            mshtBlockSignature = brReader.ReadInt16();
            if (blnUnicode) mintCRC = brReader.ReadInt32();
            m64BIDraw = blnUnicode ? brReader.ReadUInt64() : Convert.ToUInt64(brReader.ReadUInt32());
            if (!blnUnicode) mintCRC = brReader.ReadInt32();
        }

        public short BlockLength
        {
            get { return mshtBlockLength; }
        }

        public short BlockSignature
        {
            get { return mshtBlockSignature; }
        }

        public int CRC
        {
            get { return mintCRC; }
        }

        public UInt64 BIDraw
        {
            get { return m64BIDraw; }
        }

        public UInt64 BID
        {
            get { return m64BIDraw >> 2; }
        }

        public bool Reserved
        {
            get { return Convert.ToBoolean(m64BIDraw & 0x1); }
        }

        public bool Internal
        {
            get { return Convert.ToBoolean((m64BIDraw & 0x2) >> 1); }
        }
    }
}
